home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
basic
/
qbnws202.zip
/
ASCIIART.ZIP
/
ASCIIART.BAS
next >
Wrap
BASIC Source File
|
1991-05-08
|
34KB
|
550 lines
'ASCIIART.BAS Copyright 1991 by
'Charles Graham, POB 58634, St. Louis, MO 63158
'All rights reserved
'FUNCTION dir$, by David Cleary, has been
'modified for use in this program.
'ASCIIART.BAS displays ASCII (text) files as
'color images on EGA or color CGA systems.
'To execute properly, QuickBASIC must be
'invoked with the /l option: i.e., QB/L.
'$INCLUDE: 'qb.bi' 'Include the QB help
' file for interrupts
DEFINT A-Z 'Variables are type INTEGER
' unless otherwised declared
DECLARE SUB capturecodes (printercode$) 'Get printer codes
DECLARE SUB checkprinter () 'Is printer available?
DECLARE SUB clearbox () 'Clear monitor window
DECLARE FUNCTION dir$ (filespec$) 'Finds *.ASC files
'The next SUB draws a window
DECLARE SUB frame (upperrow, leftcolumn, lowerrow, rightcolumn, foreground)
DECLARE SUB getmonitor (monitortype$) 'Is it EGA or CGA?
DECLARE SUB getprinter (printertype$) 'What kind of printer?
DECLARE SUB heading () 'Print heading
DECLARE SUB loadarray (monitortype$) 'Set color attributes
DECLARE SUB printnames () 'Print file names
DECLARE SUB printpicture (n$) 'Print picture
DECLARE SUB viewpicture (monitortype$, n$, scrn) 'View picture
ON ERROR GOTO enditall 'Just in case
DIM SHARED forecolor(255) 'Dimension array
DIM SHARED inreg AS regtype, outreg AS regtype 'Define inreg and outreg
'as regtype
DIM SHARED dos 'Used with FUNCTION dir$
DIM SHARED dta AS STRING * 44 'Used with FUNCTION dir$
DIM SHARED findfirst 'Used with FUNCTION dir$
DIM SHARED findnext 'Used with FUNCTION dir$
DIM SHARED null$ 'Used with FUNCTION dir$
DIM SHARED regs AS regtypex 'Used with FUNCTION dir$
DIM SHARED setdta 'Used with FUNCTION dir$
dos = &H21 'Used with FUNCTION dir$
findfirst = &H4E00 'Used with FUNCTION dir$
findnext = &H4F00 'Used with FUNCTION dir$
null$ = CHR$(0) 'Used with FUNCTION dir$
setdta = &H1A00 'Used with FUNCTION dir$
COLOR 7, 0 'White on black
CLS 'Clear screen
CALL getmonitor(monitortype$) 'Is it EGA or CGA?
CALL loadarray(monitortype$) 'Set color attributes
CALL getprinter(printertype$) 'What kind of printer?
CALL printnames 'Print file names
DO WHILE n$ <> "DIANE" AND n$ <> "FRANCES" AND n$ <> "OTHER"
n$ = "" 'Initialize file name to null
IF scrn <> 0 THEN 'SCREEN mode not 0?
CLS ' Clear screen
IF monitortype$ = "C" THEN ' CGA?
WIDTH 80, 25 ' Invoke 80x25 text mode
END IF '
SCREEN 0 ' Invoke SCREEN mode 0
scrn = 0 ' Set indicator to 0
CALL frame(4, 12, 21, 66, 13) ' Draw a window
CALL heading ' Print heading
CALL printnames ' Print file names
ELSE 'SCREEN mode is 0
LOCATE 19, 13, 0 ' Position cursor
PRINT SPACE$(52); ' Clear line
END IF '
COLOR 15 'Bright white
LOCATE 19, 27, 1 'Position cursor
PRINT "Name of picture? "; 'Ask user for file name
COLOR 13 'Bright magenta
LINE INPUT ; ""; n$ 'Null prompt
IF n$ = "" THEN 'File name null?
EXIT DO ' T-T-That's all folks
ELSE 'File name not null
n$ = UCASE$(n$) ' Convert name to upper case
END IF '
IF n$ = "DIANE" OR n$ = "FRANCES" OR n$ = "OTHER" THEN
CLOSE 'CLOSE any open files
OPEN n$ + ".ASC" FOR INPUT AS 1 'OPEN selected file
IF printertype$ <> "N" THEN 'Printer selected?
LOCATE 19, 13, 0 ' Position cursor
PRINT SPACE$(52); ' Clear line
LOCATE 19, 29, 1 ' Position cursor
COLOR 15 ' Bright white
PRINT "Print or View [P/V]? "; ' Print it or display it?
selection$ = "" ' Initialize to null
WHILE selection$ <> "P" AND selection$ <> "V" 'Wait for P or V
selection$ = UCASE$(INKEY$) ' Make it upper case
WEND ' Got it
PRINT selection$; ' Show user
IF selection$ = "P" THEN ' Print it?
CALL printpicture(n$) ' Print picture
ELSE ' View it?
CALL viewpicture(monitortype$, n$, scrn)'View picture
END IF '
ELSE 'No printer selected
CALL viewpicture(monitortype$, n$, scrn)'View picture
END IF '
END IF '
n$ = "" 'Initialize file name to null
LOOP '
enditall: 'Just in case
IF scrn <> 0 THEN 'SCREEN mode not 0?
SCREEN 0 ' Set SCREEN mode to 0
COLOR 7, 0 ' White on black
CLS ' Clear screen
ELSE 'SCREEN mode 0
LOCATE 19, 13, 0 ' Position cursor
PRINT SPACE$(52); ' Clear line
END IF '
COLOR 31, 0 'Blink bright white on black
SELECT CASE ERR 'Any errors?
CASE 0 ' No?
SELECT CASE printertype$ ' What type of printer?
CASE "C" ' Custom?
printercode$ = "" ' Initialize to null
CALL clearbox ' Clear monitor window
LOCATE 12, 21, 0 ' Position cursor
COLOR 14 ' Bright yellow
PRINT "Enter the numeric ASCII value of each"
LOCATE 13, 20 ' Position cursor
PRINT "character you want sent to your printer."
LOCATE 14, 22 ' Position cursor
PRINT "Press the RETURN key after each one."
LOCATE 16, 27